//
//  JoPhotoTableViewCell.m
//  RunningMan
//
//  Created by 姜勇利 on 16/5/23.
//  Copyright © 2016年 JohnnyB. All rights reserved.
//

#import "JoPhotoTableViewCell.h"
#import "masonry.h"


@implementation JoPhotoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.photoImage = [[UIImageView alloc]init];
        [self.contentView addSubview:self.photoImage];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    if (_photoImage.image.size.width < self.contentView.frame.size.width) {
        [self.photoImage mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView).with.offset(0);
            make.left.equalTo(self.contentView).with.offset(10);
            make.width.mas_equalTo(_photoImage.image.size.width);
            make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-10);
        }];
    }
    else{
         [self.photoImage mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView.mas_top).with.offset(0);
            make.bottom.equalTo(self.contentView.mas_bottom).with.offset(-10);
            make.left.equalTo(self.contentView.mas_left).with.offset(10);
            make.right.equalTo(self.contentView.mas_right).with.offset(-10);
        }];
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
